在Ubuntu命令行中卸载安装包,主要使用 aptdpkg 工具。以下是详细步骤:


1. 卸载软件包(保留配置文件)

sudo apt remove <包名>
  • 示例:卸载Firefox

    sudo apt remove firefox
    

2. 彻底卸载(删除配置文件)

sudo apt purge <包名>
  • 示例:彻底删除Firefox及其配置

    sudo apt purge firefox
    

3. 自动清理无用依赖

卸载后,删除不再需要的依赖包:

sudo apt autoremove

4. 查找已安装的包名

  • 方法1:列出所有已安装的包

    apt list --installed
    
  • 方法2:通过关键字搜索(如搜索python相关包)

    dpkg -l | grep python
    

5. 注意事项

  • 确认包名:卸载前务必确认包名正确,避免误删。
  • Snap包:如果是通过 snap 安装的包,需用:

    sudo snap remove <包名>
    
  • 依赖安全谨慎使用 --auto-remove 参数,可能误删其他包的依赖。

完整示例:卸载VS Code

  1. 查找包名:

    dpkg -l | grep code
    

    输出可能为 code

  2. 卸载并删除配置:

    sudo apt purge code
    
  3. 清理残留依赖:

    sudo apt autoremove
    

通过上述步骤,你可以安全高效地管理Ubuntu系统中的软件包!

Copyright © https://yan-jian.com 2023 all right reserved更新时间: 2025-05-28 14:59:26

results matching ""

    No results matching ""